<template>
  <div class="page-box">
    <el-card class="page-box-card">
      <el-tabs v-model="activeName" @tab-click="changeTabGetData">
        <el-tab-pane label="待随访" name="first">
          <el-form
            :model="queryParams"
            ref="queryForm"
            size="small"
            label-width="88px"
            inline
          >
            <el-form-item label="身份证号" prop="param.idCard">
              <el-input
                style="width: 240px"
                v-model="queryParams.param.idCard"
                placeholder="请输入身份证号"
                clearable
              ></el-input>
            </el-form-item>
            <el-form-item label="姓名" prop="param.name">
              <el-input
                style="width: 240px"
                v-model="queryParams.param.name"
                placeholder="请输入姓名"
                clearable
              ></el-input>
            </el-form-item>
            <!-- <el-form-item label="入院日期" prop="param.enterTime">
              <el-date-picker
                v-model="queryParams.param.enterTime"
                type="daterange"
                align="right"
                unlink-panels
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item> -->
            <!-- <el-form-item label="档案状态" prop="param.auditStatus">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.auditStatus"
                placeholder="请选择档案状态"
                clearable
              >
                <el-option label="未提交" value="0"> </el-option>
                <el-option label="已提交" value="1"> </el-option>
                <el-option label="已审核" value="2"> </el-option>
                <el-option label="已驳回" value="3"> </el-option>
              </el-select>
            </el-form-item> -->
            <!-- <el-form-item label="档案号" prop="param.fileNum">
              <el-input
                style="width: 240px"
                v-model="queryParams.param.fileNum"
                placeholder="请输入档案号"
                clearable
              ></el-input>
            </el-form-item> -->
            <!-- <el-form-item label="所属项目" prop="param.projectId">
              <el-select
                style="width: 240px"
                clearable
                v-model="queryParams.param.projectId"
                placeholder="请选择所属项目"
              >
                <el-option v-for="item in projectList" :key="item.id" :label="item.topicShortName" :value="item.id"> </el-option>
              </el-select>
            </el-form-item> -->
            <el-form-item label="所属科室" prop="param.departmentId">
              <el-input
                v-model="queryParams.param.departmentId"
                placeholder="请输入所属科室"
                clearable
                style="width: 240px"
                @keyup.enter.native="handleQuery"
              />
              <!-- <el-select
                style="width: 240px"
                v-model="queryParams.param.departmentId"
                placeholder="请选择所属科室"
              >
                <el-option label="神经内科一" value="神经内科一"> </el-option>
                <el-option label="神经内科二" value="神经内科二"> </el-option>
                <el-option label="神经外科一" value="神经外科一"> </el-option>
                <el-option label="神经外科二" value="神经外科二"> </el-option>
              </el-select> -->
            </el-form-item>
            <!-- <el-form-item label="数据来源" prop="param.source">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.source"
                placeholder="请选择数据来源"
                clearable
              >
                <el-option
                  v-for="item in dict.type.data_source"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item> -->
            <el-form-item label="危险分级" prop="param.riskLevel">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.riskLevel"
                placeholder="请选择危险分级"
                clearable
              >
                <el-option
                  v-for="item in dict.type.strategy_danger_level"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="治疗类型" prop="param.treatmentTypes">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.treatmentTypes"
                placeholder="请选择治疗类型"
                multiple
                clearable
              >
                <el-option label="AIS静脉溶栓" value="1"> </el-option>
                <el-option label="AIS介入再通" value="2"> </el-option>
                <el-option label="脑出血" value="3"> </el-option>
                <el-option label="颅内动脉瘤" value="4"> </el-option>
                <el-option label="CES/CAS" value="5"> </el-option>
              </el-select>
            </el-form-item> -->
            <el-form-item label="待随访轮次" prop="param.pendingFollowUp">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.pendingFollowUp"
                placeholder="请选择待随访轮次"
                clearable
              >
                <el-option label="3个月" value="3"> </el-option>
                <el-option label="6个月" value="6"> </el-option>
                <el-option label="12个月" value="12"> </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="是否超期" prop="param.lostFlupFlag">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.lostFlupFlag"
                placeholder="请选择是否超期"
                clearable
              >
                <el-option label="是" value="0"> </el-option>
                <el-option label="否" value="1"> </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="住院时间" prop="param.enterTime">
              <el-date-picker
                v-model="queryParams.param.enterTime"
                type="daterange"
                align="right"
                unlink-panels
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item label="出院时间" prop="param.leaveTime">
              <el-date-picker
                v-model="queryParams.param.leaveTime"
                type="daterange"
                align="right"
                unlink-panels
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="small"
                @click="handleQuery"
                >搜索</el-button
              >
              <el-button icon="el-icon-refresh" size="small" @click="resetQuery"
                >重置</el-button
              >
            </el-form-item>
          </el-form>
          <el-row :gutter="10" class="mb8">
            <!-- <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['definition:class:add']"
            >新增</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleEdit"
            v-hasPermi="['definition:class:edit']"
            >修改</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['definition:class:delete']"
            >删除</el-button
          >
        </el-col> -->
            <el-col :span="1.5">
              <el-button
                type="warning"
                plain
                icon="el-icon-download"
                size="mini"
                v-hasPermi="['definition:class:download']"
                @click="downloadData"
                >导出</el-button
              >
            </el-col>
          </el-row>
          <el-table
            v-loading="loading"
            :data="dataList"
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55" align="center" fixed />
            <el-table-column
              type="index"
              label="序号"
              width="55"
              align="center"
              fixed
            />
            <!-- <el-table-column prop="projectName" label="所属项目" width="180">
            </el-table-column> -->
            <el-table-column prop="fileNum" label="档案号" width="120">
            </el-table-column>
            <el-table-column prop="idcard" label="身份证号" width="180">
            </el-table-column>
            <el-table-column prop="name" label="姓名" width="100">
            </el-table-column>
            <el-table-column prop="sex" label="性别" width="100">
              <template slot-scope="scope">
                <dict-tag
                  :options="dict.type.sys_user_sex"
                  :value="scope.row.sex - 0"
                />
              </template>
            </el-table-column>
            <el-table-column prop="enterTime" label="住院时间" width="180">
            </el-table-column>
            <el-table-column prop="leaveTime" label="出院时间" width="180">
            </el-table-column>
            <el-table-column prop="riskLevel" label="危险分级" align="center">
              <template slot-scope="scope">
                <dict-tag
                  :options="dict.type.strategy_danger_level"
                  :value="scope.row.riskLevel"
                />
              </template>
            </el-table-column>
            <!-- <el-table-column
              prop="treatmentTypes"
              label="治疗类型"
              align="center"
              width="180"
            >
              <template slot-scope="scope">
                <template v-if="scope.row.treatmentType">
                <div
                  v-for="(item, index) in scope.row.treatmentType.split(',')"
                  :key="index"
                >
                  <span v-if="item == 1">
                    AIS静脉溶栓
                  </span>
                  <span v-else-if="item == 2">
                    AIS介入再通
                  </span>
                  <span v-else-if="item == 3">
                    脑出血
                  </span>
                  <span v-else-if="item == 4">
                    颅内动脉瘤
                  </span>
                  <span v-else-if="item == 5">
                    CES/CAS
                  </span>
                  <span
                    v-if="
                      index != scope.row.treatmentType.split(',').length - 1
                    "
                    >，</span
                  >
                </div>
                </template>
              </template>
            </el-table-column> -->
            <el-table-column prop="lostFlupFlag" label="是否超期" width="100">
              <template slot-scope="scope">
                <div v-if="scope.row.lostFlupFlag == '0'">是</div>
                <div v-else-if="scope.row.lostFlupFlag == '1'">否</div>
              </template>
            </el-table-column>
            <!-- <el-table-column prop="" label="所属科室" width="220">
            </el-table-column> -->
            <!-- <el-table-column prop="source" label="数据来源" width="220">
            </el-table-column> -->
            <!-- <el-table-column prop="" label="建档单位" width="220">
            </el-table-column>
            <el-table-column prop="" label="随访人" width="220">
            </el-table-column>
            <el-table-column prop="flupTime" label="随访时间" width="220">
            </el-table-column>
            <el-table-column prop="" label="审核人" width="220" />
            <el-table-column prop="" label="审核时间" width="220" /> -->
            <!-- <el-table-column prop="auditStatus" label="档案状态" width="100">
              <template slot-scope="scope">
                <div v-if="scope.row.auditStatus == '0'">未提交</div>
                <div v-else-if="scope.row.auditStatus == '1'">已提交</div>
                <div v-else-if="scope.row.auditStatus == '2'">已审核</div>
                <div v-else-if="scope.row.auditStatus == '3'">已驳回</div>
              </template>
            </el-table-column> -->
            <el-table-column
              label="操作"
              align="center"
              fixed="right"
              width="160"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleEdit(scope.row)"
                  v-hasPermi="['system:dept:edit']"
                  >创建</el-button
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-tab-pane>
        <el-tab-pane label="已随访" name="second">
          <el-form
            :model="queryParams"
            ref="queryForm"
            size="small"
            label-width="88px"
            inline
          >
            <el-form-item label="身份证号" prop="param.idCard">
              <el-input
                style="width: 240px"
                v-model="queryParams.param.idCard"
                placeholder="请输入身份证号"
              ></el-input>
            </el-form-item>
            <el-form-item label="姓名" prop="param.name">
              <el-input
                v-model="queryParams.param.name"
                style="width: 240px"
                placeholder="请输入姓名"
              ></el-input>
            </el-form-item>
            <el-form-item label="已随访轮次" prop="param.followedUp">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.followedUp"
                placeholder="请选择待已随访轮次"
              >
                <el-option label="3个月" value="3"> </el-option>
                <el-option label="6个月" value="6"> </el-option>
                <el-option label="12个月" value="12"> </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="随访状态" prop="param.followedUpStatus">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.followedUpStatus"
                placeholder="请选择随访状态"
                multiple
              >
                <el-option label="未提交" value="0"> </el-option>
                <el-option label="待审核" value="1"> </el-option>
                <el-option label="已通过" value="2"> </el-option>
                <el-option label="未通过" value="3"> </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="是否死亡" prop="param.deathFlag">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.deathFlag"
                placeholder="请选择是否死亡"
              >
                <el-option label="是" value="0"> </el-option>
                <el-option label="否" value="1"> </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="是否失访" prop="param.lostFlupFlag">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.lostFlupFlag"
                placeholder="请选择是否失访"
              >
                <el-option label="是" value="0"> </el-option>
                <el-option label="否" value="1"> </el-option>
              </el-select>
            </el-form-item>
            <!-- <el-form-item label="档案号" prop="param.fileNum">
              <el-input
                style="width: 240px"
                v-model="queryParams.param.fileNum"
                placeholder="请输入档案号"
              ></el-input>
            </el-form-item> -->
            <!-- <el-form-item label="所属项目" prop="param.projectId">
              <el-select
                style="width: 240px"
                clearable
                v-model="queryParams.param.projectId"
                placeholder="请选择所属项目"
              >
                <el-option v-for="item in projectList" :key="item.id" :label="item.topicShortName" :value="item.id"> </el-option>
              </el-select>
            </el-form-item> -->
            <el-form-item label="所属科室" prop="param.departmentId">
              <el-input
                v-model="queryParams.param.departmentId"
                placeholder="请输入所属科室"
                clearable
                style="width: 240px"
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <!-- <el-form-item label="数据来源" prop="param.source">
              <el-select
                style="width: 240px"
                v-model="queryParams.param.source"
                placeholder="请选择数据来源"
              >
                <el-option
                  v-for="item in dict.type.data_source"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item> -->
            <el-form-item label="住院时间" prop="param.enterTime">
              <el-date-picker
                v-model="queryParams.param.enterTime"
                type="daterange"
                align="right"
                unlink-panels
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item label="出院时间" prop="param.leaveTime">
              <el-date-picker
                v-model="queryParams.param.leaveTime"
                type="daterange"
                align="right"
                unlink-panels
                value-format="yyyy-MM-dd"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="small"
                @click="handleQuery"
                >搜索</el-button
              >
              <el-button icon="el-icon-refresh" size="small" @click="resetQuery"
                >重置</el-button
              >
            </el-form-item>
          </el-form>
          <el-row :gutter="10" class="mb8">
            <!-- <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['definition:class:add']"
            >新增</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleEdit"
            v-hasPermi="['definition:class:edit']"
            >修改</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['definition:class:delete']"
            >删除</el-button
          >
        </el-col> -->
            <el-col :span="1.5">
              <el-button
                type="warning"
                plain
                icon="el-icon-download"
                size="mini"
                v-hasPermi="['definition:class:download']"
                @click="downloadData"
                >导出</el-button
              >
            </el-col>
          </el-row>
          <el-table
            v-loading="loading"
            :data="dataList"
            style="width: 100%"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55" align="center" fixed />
            <el-table-column
              type="index"
              label="序号"
              width="55"
              align="center"
              fixed
            />
            <!-- <el-table-column prop="projectName" label="所属项目" width="180">
            </el-table-column> -->
            <el-table-column prop="fileNum" label="档案号" width="180">
            </el-table-column>
            <el-table-column prop="idcard" label="身份证号" width="180">
            </el-table-column>
            <el-table-column prop="name" label="姓名" width="100">
            </el-table-column>
            <el-table-column prop="sex" label="性别" width="100">
              <template slot-scope="scope">
                <dict-tag
                  :options="dict.type.sys_user_sex"
                  :value="scope.row.sex - 0"
                />
              </template>
            </el-table-column>
            <el-table-column prop="" label="随访编号" width="180">
            </el-table-column>
            <el-table-column prop="round" label="随访轮次" width="100">
            </el-table-column>
            <el-table-column prop="flupFlag" label="随访状态" width="100">
              <template slot-scope="scope">
                <el-tag v-if="scope.row.flupFlag == '1'" type="success">已随访</el-tag>
                <el-tag v-else-if="scope.row.flupFlag == '0'" type="info">待随访</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="" label="所属科室" width="220">
            </el-table-column>
            <!-- <el-table-column prop="source" label="数据来源" width="220">
            </el-table-column> -->
            <el-table-column prop="" label="建档单位" width="220">
            </el-table-column>
            <el-table-column prop="" label="随访人" width="220">
            </el-table-column>
            <el-table-column prop="flupTime" label="随访时间" width="220">
            </el-table-column>
            <el-table-column prop="" label="审核人" width="220" />
            <el-table-column prop="" label="审核时间" width="220" />
            <el-table-column
              label="操作"
              align="center"
              fixed="right"
              width="160"
            >
              <template slot-scope="scope">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleEdit(scope.row)"
                  v-hasPermi="['system:dept:edit']"
                  >创建</el-button
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          />
        </el-tab-pane>
      </el-tabs>
    </el-card>
    <!-- 添加或修改对话框 -->
    <el-dialog
      :title="title"
      :visible.sync="addDialog"
      width="800px"
      append-to-body
    >
      <el-form ref="form" :model="addForm" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="类别" prop="type">
              <el-select
                style="width: 100%"
                v-model="addForm.type"
                placeholder="请选择类别"
              >
                <el-option
                  v-for="item in dict.type.strategy_type"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value - 0"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="危险分级" prop="riskLevel">
              <el-select
                style="width: 100%"
                v-model="addForm.riskLevel"
                placeholder="请选择危险分级"
              >
                <el-option
                  v-for="item in dict.type.strategy_danger_level"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value - 0"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="随访轮次" prop="roundList">
              <el-checkbox-group v-model="addForm.roundList">
                <el-checkbox label="3">3个月</el-checkbox>
                <el-checkbox label="6">6个月</el-checkbox>
                <el-checkbox label="9">9个月</el-checkbox>
                <el-checkbox label="12">12个月</el-checkbox>
                <el-checkbox label="24">24个月</el-checkbox>
                <el-checkbox label="长期">长期</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="变量类别" prop="required">
              <el-radio-group v-model="addForm.required">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col> -->
          <el-col :span="24">
            <el-form-item label="策略内容" prop="content">
              <el-input
                style="width: 100%"
                type="textarea"
                :rows="6"
                placeholder="请输入内容"
                v-model="addForm.content"
              >
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import {
  getListFlupInfo,
  insertFlupInfo,
  updateFlupInfo,
  deleteFlupInfo,
  exportData,
} from "@/api/followUp/archives";
import {
  listProject,
} from "@/api/data/topic";
export default {
  dicts: ["strategy_type", "strategy_danger_level", "data_source", "sys_user_sex"],
  data() {
    return {
      activeName: "first",
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      selectionData: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        param: {
          idCard: '',
          name: '',
          enterTime: null,
          auditStatus: null,
          fileNum: null,
          projectId: null,
          departmentId: null,
          source: null,
          riskLevel: null,
          treatmentTypes: [],
          pendingFollowUp: '',
          lostFlupFlag: '',
          type: "",
          flupFlag: "0",
        },
      },
      tagList: [],
      dataList: [],
      total: 0,
      title: "",
      addDialog: false,
      addForm: {
        type: "",
        riskLevel: "",
        roundList: [],
        round: "",
        content: "",
      },
      rules: {
        text: [{ required: true, message: "请输入变量名称", trigger: "blur" }],
        code: [{ required: true, message: "请输入变量CODE", trigger: "blur" }],
      },
      projectList: [],
    };
  },
  created() {
    const query = this.$route.query;
    if (query.userName) {
      this.activeName = "second";
      this.queryParams.param.name = query.userName;
      this.queryParams.param.fileNum = query.fileNum;
    }
    this.getList();
    this.getProjectList();
  },
  methods: {
    changeTabGetData() {
      console.log('activeName: ', this.activeName);
    },
    // 获取数据列表
    getProjectList() {
      const param = {
        pageNum: 1,
        param: {
          name: "",
        },
      };
      console.log("param: ", param);
      listProject(param).then((response) => {
        this.projectList = [ ...response.data.list ];
        console.log('this.projectList: ', this.projectList);
      });
    },
    // 导出数据
    downloadData() {
      const that = this;
      this.$modal
        .confirm("是否确认导出当前查询条件下的数据？")
        .then(function () {
          // 导出
          const params = that.queryParams;
          return that.download(
            exportData,
            { ...params.param },
            `筛查随访档案_${new Date().getTime()}.xlsx`
          );
        })
        .then((res) => {
          that.$message.success("导出成功");
        })
        .catch(() => {});
    },
    // 搜索事件
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置事件
    resetQuery() {
      this.dataList = [];
      this.total = 0;
      this.queryParams.pageNum = 1;
      this.queryParams.pageSize = 10;
      // this.resetForm("queryForm");
      this.queryParams.param = {
        idCard: '',
        name: '',
        enterTime: null,
        auditStatus: null,
        fileNum: null,
        projectId: null,
        departmentId: null,
        source: null,
        riskLevel: null,
        treatmentTypes: [],
        pendingFollowUp: '',
        lostFlupFlag: '',
        type: "",
        flupFlag: "0",
      }
      this.handleQuery();
    },
    // 获取数据列表
    getList() {
      this.loading = true;
      const params = JSON.parse(JSON.stringify(this.queryParams));
      if (params.param.treatmentTypes) {
        params.param.treatmentType = params.param.treatmentTypes.toString();
      } else {
        params.param.treatmentType = "";
      }
      if (params.param.enterTime) {
        params.param.enterTimeStart = params.param.enterTime[0];
        params.param.enterTimeEnd = params.param.enterTime[1];
      } else {
        params.param.enterTimeStart = null;
        params.param.enterTimeEnd = null;
      }
      if (params.param.leaveTime) {
        params.param.leaveTimeStart = params.param.leaveTime[0];
        params.param.leaveTimeEnd = params.param.leaveTime[1];
      } else {
        params.param.leaveTimeStart = null;
        params.param.leaveTimeEnd = null;
      }
      getListFlupInfo(params).then((response) => {
        this.dataList = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 列表选中事件
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.selectionData = [...selection];
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    // 新增变量
    handleAdd() {
      this.title = "新增随访策略";
      this.addDialog = true;
    },
    // 新增/修改弹框提交事件
    async submitForm() {
      const param = { ...this.addForm };
      if (param.roundList.length) {
        param.round = param.roundList.join(",");
      } else {
        param.round = "";
      }
      if (param.id) {
        // 修改
        await updateFlupInfo(param).then((res) => {
          this.$message.success("修改成功");
          this.cancel();
          this.handleQuery();
        });
      } else {
        // 新增
        await insertFlupInfo(param).then((res) => {
          this.$message.success("新增成功");
          this.cancel();
          this.handleQuery();
        });
      }
    },
    // 新增/修改弹框取消事件
    cancel() {
      this.addForm = {
        type: "",
        riskLevel: "",
        roundList: [],
        round: "",
        content: "",
      };
      this.addDialog = false;
    },
    // 修改变量
    handleEdit(row) {
      this.$message.warning("创建随访记录");
      // this.title = "修改策略";
      // const data = row.id ? row : this.selectionData[0];
      // this.addForm = {
      //   ...data,
      //   roundList: data.round.split(","),
      // };
      // this.addDialog = true;
    },
    // 删除策略
    handleDelete(row) {
      const idList = row.id ? [row.id] : [...this.ids];
      this.$modal
        .confirm("是否确认删除当前选择的策略？")
        .then(function () {
          // 删除
          return deleteFlupInfo({ idList });
        })
        .then(() => {
          this.$message.success("删除成功");
          this.handleQuery();
        })
        .catch(() => {});
    },
  },
};
</script>
<style lang="scss">
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.row-1 {
  width: 20%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-3 {
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
